package de.vocabulary.client.editor;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.google.gwt.user.client.ui.SuggestOracle;


public class StupidOracle extends SuggestOracle {
	
	private List<Suggestion> suggestions = new ArrayList<Suggestion>();
	
	public void add(String option){
		suggestions.add(new ItemSuggestion(option));
	}
	
	  /**
	   * Adds all suggestions specified. Each suggestion must be plain text.
	   *
	   * @param collection the collection
	   */
	  public final void addAll(Collection<String> collection) {
	    for (String suggestion : collection) {
	      add(suggestion);
	    }
	  }
	
	public boolean isDisplayStringHTML() {
        return true;
    }

	@Override
	public void requestSuggestions(Request request, Callback callback) {
		SuggestOracle.Response resp = new SuggestOracle.Response();
	    resp.setSuggestions(suggestions);
		callback.onSuggestionsReady(request, resp);

	}

	public void setSuggestions(List<String> list) {
		suggestions.clear();
		addAll(list);		
	}

}
